from graphviz import Digraph

def draw_ast(node, dot=None):
    if dot is None:
        dot = Digraph(comment='AST')

    dot.node(str(id(node)), label=node.__class__.__name__)

    for child in node.children():
        dot.node(str(id(child)), label=child.__class__.__name__)
        dot.edge(str(id(node)), str(id(child)))
        draw_ast(child, dot)

    return dot